<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$ChannelName}|{$Title}-{$WebName}</title>
<include file="Public:meta" />
<script type="text/javascript" src="{$WebPublic}jquery/jquery.form.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#frmGuestBook').ajaxForm({
			success: complete,
			dataType: 'json',
			beforeSubmit: check
		});
		
		function check(){
			<guestbookmodellist id="f">
					<eq name="f.IsRequire" value="1">
							if($("#{$f.FieldName}").val()==""){
								alert("{$f.DisplayName}{$Think.lang.Required}");
								$("#{$f.FieldName}").focus();
								return false;
							}
					</eq>
					
					<eq name="f.IsValidate" value="1">
						<notempty name="f.ValidateRule">
								var re = new RegExp("{$f.ValidateRule}");
								if(!re.test( $("#{$f.FieldName}").val() )){
									alert("{$f.DisplayName}{$Think.lang.Invalid}");
									$("#{$f.FieldName}").focus();
									return false;
								}
						</notempty>
					</eq>
			</guestbookmodellist>
			<eq name="OrderVerifyCode" value="1">
				if( $("#verifycode").val() == ""){
					alert("{$Think.lang.VerifyCodeRequired}");
					$("#verifycode").focus();
					return false;
				}
			</eq>
			return true;
		}
		
		function complete(data){
			if (data.status==1){
				alert(data.info);
				$('#frmGuestBook').resetForm();
            }else if(data.status==0){
				alert(data.info);
			}
			ChangeCode();
		};
		
		 $('#frmGuestBook').submit(function(){  // 提交表单
	     	//$('#frmAddBanner').ajaxSubmit();  
	     	return false;  //为了防止普通浏览器进行表单提交和产生页面导航（防止页面刷新？）返回false  
	     });
	});
</script>
<script>
	function ChangeCode(){
		var timenow = new Date().getTime();
		var obj = document.getElementById('code');
		if( obj ) obj.src = "{$Group}/public/guestbookCode/"+timenow;
	}
</script>
</head>
<body class="body_guestbook">
	<include file="Public:header" />
    <!--主体内容 开始-->
    <div class="guestbook">
    		<!--左侧区域 开始-->
			<div id="left">
                <include file="Public:subchannel" />
                <include file="Public:search" />
                <include file="Public:contact" />
			</div>
            <!--左侧区域 结束-->
            
            <!--右侧区域 开始-->
			<div id="right">
                <div class="right_title">
                	<include file="Public:location" />
                    <h2>{$ChannelName}</h2>
                </div>
            	<div class="right_body">
                	<ul class="guestbooklist">
                    <guestbooklist id="b" nowpage="$NowPage" empty="$Think.lang.NoInformation">
                            <li>
                                <div class="MessageTitle">
                                    {$Think.lang.YourName}:<b class="purple">{$b.GuestName}</b>&nbsp;
                                    IP:<b class="purple">{$b.GuestIP}</b>&nbsp;
                                    {$Think.lang.MessageTime}:<b class="gray">{$b.MessageTime}</b><br/>
                                	<b>{$Think.lang.MessageTitle}</b>：{$b.MessageTitle}
                                </div>
                                <div class="MessageContent">{$b.MessageContent}</div>
                                <notempty name="b.AnswerContent">
                                    <div class="answer_wrap">
                                        <div class="answer_title">
                                             <span class="Administrator">{$Think.lang.Administrator}</span>
                                            <span class="AnswerTime">（{$b.AnswerTime}）</span>
                                            <span class="Reply">{$Think.lang.Reply}</span>：
                                        </div>
                                        <div class="answer_body">{$b.AnswerContent}</div>
                                     </div>
                                </notempty>
                        	</li>
                    </guestbooklist>        
                    </ul>     
                    <div class="page">{$Page}</div>    
                    <div class="clear"></div>
                    <div class="message_title">{$Think.lang.LeaveMessage}</div>
                    <div class="message_body" >
                        <table class="guestbook_table">
                            <form enctype="multipart/form-data" method="post" id="frmGuestBook" action="{:GuestbookAddAction()}">
                            <guestbookmodellist id="f">
                                <tr>
                                    <th>{$f.DisplayName}<eq name='f.IsRequire' value='1'><span class="required">*</span></eq></th>
                                    <td>
                                    <switch name="f.DisplayType">
                                        <case value="textarea">
                                            <textarea id="{$f.FieldName}"   name="{$f.FieldName}" class="form_textarea">{$f.DisplayValue}</textarea>
                                        </case>
                                        <case value="radio">
                                            <volist name="f.Item" id="it">
                                                   <input id="{$f.FieldName}" name="{$f.FieldName}" type="radio" class="form_radio"  value="{$it.Value}"  {$it.Selected}  />{$it.Text}&nbsp;&nbsp;
                                            </volist>
                                        </case>
                                       <case value="checkbox">
                                            <volist name="f.Item" id="it">
                                                   <input id="{$f.FieldName}"  class="form_checkbox"  name="{$f.FieldName}[]" value="{$it.Value}" type="checkbox" {$it.Selected} />{$it.Text}&nbsp;&nbsp;
                                            </volist>
                                        </case>
                                        <case value="select">
                                            <select  id="{$f.FieldName}"  name="{$f.FieldName}" >
                                                <volist name="f.Item" id="it">
                                                        <option  value="{$it.Value}"  {$it.Selected} >{$it.Text}</option>
                                                </volist>
                                             </select>
                                        </case>
                                        <case value="label">{$f.DisplayValue}</case>
                                        <case value="password"><input id="{$f.FieldName}" name="{$f.FieldName}" type="password"   class="form_text"  value="{$f.DisplayValue}" /></case>
                                        <default /><input id="{$f.FieldName}" name="{$f.FieldName}" type="text"   class="form_text"  maxlength="100"   value="{$f.DisplayValue}" />
                                     </switch>
                                     </td>
                                 </tr>
                            </guestbookmodellist>
                            
                            <eq name="GuestBookVerifycode" value="1">
                                <tr>
                                    <th>{$Think.lang.Verifycode}<span class="required">*</span></th>
                                    <td>
                                    <input id="verifycode" class="form_text_verifycode" name="verifycode" type="text" maxlength="4" />
                                    <img  src="{$Group}/public/guestbookCode/"  onclick="ChangeCode()"  class="code_image" id="code"  align="absMiddle"  alt="{$Think.lang.ChangeVerifycode}"  title="{$Think.lang.ChangeVerifycode}" />
                                    </td>
                                </tr>
                            </eq>
                            <tr>
                                <td colspan="2" class="operation"><input class="form_button btn"  type="submit" name="submit8" value="{$Think.lang.Submit}" /></td>
                            </tr>
                            </form>
                        </table>
                    </div>
                </div>
                <div class="right_bottom"></div>
			</div>
            <!--右侧区域 结束-->
		    <div class="clear"></div>
	</div>
    <!--主体内容 结束-->
    <include file="Public:footer" />
</body>
</html>